/*******************************************************************************
 * Copyright (c) 2009-2011 ETCORE Labs. All rights reserved. 
 * 
 * This software is the confidential and proprietary information of ETCORE Labs.
 * You shall not disclose such confidential information and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with ETCORE Labs. 
 * 
 * Support can be obtained from support forums at:  http://www.etcore.com/
 * /
 *******************************************************************************/
package etcore.webapp.grouptalk.common.config;

import java.util.Iterator;
import java.util.Map;

public class Messages {
	public static final String ACCESS_BOOKMARKS = "access_bookmarks";
	public static final String ACCESS_INTERNAL_OPEN = "access_internal_open";
	public static final String ACCESS_OPEN_READ = "access_open_read";
	public static final String ACCESS_OPEN_WRITE = "access_open_write";
	public static final String ACCESS_REMINDERS = "access_reminders";
	public static final String ADD = "add";
	public static final String ADD_DIR = "add_dir";
	public static final String ADD_GROUP = "add_group";
	public static final String ADD_TOPIC = "add_topic";
	public static final String ALLOW_MANUSCRIPT = "allow_manuscript";
	public static final String BUTTON_BACK = "button_back";
	public static final String BUTTON_OK = "button_ok";
	public static final String BUTTON_RESET = "button_reset";
	public static final String CONTACTUS = "contactus";
	public static final String CONTACTUS_CONTENT = "contactus_content";
	public static final String CURRENT_PAGE = "current_page";
	public static final String DAYS = "days";
	public static final String MANAGE_TOPIC = "manage_topic";
	public static final String DEGRADE = "degrade";
	public static final String DEL = "del";
	public static final String DEL_MSG = "del_msg";
	public static final String DEL_TOPIC = "del_topic";
	public static final String DESCRIPTION = "description";
	public static final String EDIT = "edit";
	public static final String EDIT_DIR = "edit_dir";
	public static final String EDIT_GROUP = "edit_group";
	public static final String EDIT_NAME = "edit_name";
	public static final String EDIT_TOPIC = "edit_topic";
	public static final String EDITPWD = "editPwd";
	private static Map<String, Map<String, String>> emessages;
	public static final String ERROR_MSG = "error_msg";
	public static final String GROUP_HOME = "group_home";
	public static final String HOMEPAGE = "homepage";
	public static final String KEYWORDS = "keywords";
	public static final String LANG_LOCAL = "local";
	public static final String LANG_AUTO = "auto";
	public static final String LANG_EN = "en";
	public static final String LAST_ACCESS = "last_access";
	public static final String LINK_TIP = "link_tip";
	public static final String LOG_NUM = "log_num";
	public static final String LOG_TIME = "log_time";
	public static final String LOGGEDNAME = "loggedName";
	public static final String LOGIN = "login";
	public static final String LOGOUT = "logout";
	public static final String MSG_UPLOAD_ERROR = "msg_upload_error";
	public static final String MANAGEMENT = "management";
	private static Map<String, Map<String, String>> messages;
	public static final String MSG_ADD_NOW = "msg_add_now";
	public static final String MSG_CONTENT_NULL = "msg_content_null";
	public static final String MSG_DEL_NOW = "msg_del_now";
	public static final String MSG_DIVIDE_SIGNAL = "msg_divide_signal";
	public static final String MSG_EDIT_NOW = "msg_edit_now";
	public static final String MSG_IMAGE_ERROR = "msg_image_error";
	public static final String MSG_LOGIN_ERROR = "msg_login_error";
	public static final String MSG_LOGIN_NOTE = "msg_login_note";
	public static final String MSG_MAIL_FORMAT = "msg_mail_format";
	public static final String MSG_MAIL_NULL = "msg_mail_null";
	public static final String MSG_MAIL_SAME = "msg_mail_same";
	public static final String MSG_MUST_CONTENT = "msg_must_content";
	public static final String MSG_NAME_CONFLICT = "msg_name_conflict";
	public static final String MSG_NAME_NULL = "msg_name_null";
	public static final String MSG_NEW_PWD_LENGTH = "msg_new_pwd_length";
	public static final String MSG_NEW_PWD_NULL = "msg_new_pwd_null";
	public static final String MSG_NEW_PWD_SAME = "msg_new_pwd_same";
	public static final String MSG_PAGE_MAX = "msg_page_max";
	public static final String MSG_PWD_ERROR = "msg_pwd_error";
	public static final String MSG_PWD_LENGTH_NOTE = "msg_pwd_length_note";
	public static final String MSG_PWD_NULL = "msg_pwd_null";
	public static final String MSG_REG_SUCESS = "msg_reg_sucess";
	public static final String MSG_SELECT_TOPIC = "msg_select_topic";
	public static final String MSG_SUCCESS = "msg_success";
	public static final String MSG_ALLOCATION_LACKNESS = "allocation_lackness";
	public static final String MSG_DATE_ERROR = "msg_date_error";
	public static final String REDUCE_OLD_ERROR = "reduce_old_error";
	public static final String MSG_TAG_INDEX = "msg_tag_index";
	public static final String MSG_TITLE = "msg_title";
	public static final String MSG_TITLE_NULL = "msg_title_null";
	public static final String MSG_TOPIC = "msg_topic";
	public static final String MSG_TOPIC_ERROR = "msg_topic_error";
	public static final String MSG_USER_NAME_SAME = "msg_user_name_same";
	public static final String MSG_USER_NULL = "msg_user_null";
	public static final String MSG_NOT_LOGGED = "msg_not_logged";
	public static final String NEXT_PAGE = "next_page";
	public static final String OPERATION = "operation";
	public static final String PAPER_MANAGEMENT = "paper_management";
	public static final String PLATFORM0 = "platform0";
	public static final String PLATFORM1 = "platform1";
	public static final String PLATFORM2 = "platform2";
	public static final String PLATFORM3 = "platform3";
	public static final String PLATFORM4 = "platform4";
	public static final String PREVIOUS_PAGE = "previous_page";
	public static final String REG_TIME = "reg_time";
	public static final String REGISTER = "register";
	public static final String ROOT_DIR = "root_dir";
	public static final String SEARCH_GROUP = "search_group";
	public static final String SORT_VIEW = "sort_view";
	public static final String SOURCE_TIME = "source_time";
	public static final String SOURCE_URL = "source_url";
	public static final String SESSION_USER = "session_user";
	public static final String TEXT_ABSTRACT = "text_abstract";
	public static final String TEXT_ACCESS = "text_access";
	public static final String TEXT_ALL = "text_all";
	public static final String TEXT_ATTACHED = "text_attached";
	public static final String TEXT_AUTHOR = "text_author";
	public static final String TEXT_CLASSED_INFO = "text_classed_info";
	public static final String TEXT_CLICK = "text_click";
	public static final String TEXT_CODE = "text_code";
	public static final String TEXT_COMMENT = "text_comment";
	public static final String TEXT_COMMON_AREA = "text_common_area";
	public static final String TEXT_CREATE_LINKS = "text_create_links";
	public static final String TEXT_DELETE_LINKS = "text_delete_links";
	public static final String TEXT_DIGEST = "text_digest";
	public static final String TEXT_DIGEST_AREA = "text_digest_area";
	public static final String TEXT_DIGEST_OFF = "text_digest_off";
	public static final String TEXT_END = "text_end";
	public static final String TEXT_FIND = "text_find";
	public static final String TEXT_GROUP = "text_group";
	public static final String TEXT_GROUP_RELATIONS = "text_group_relations";
	public static final String TEXT_HOT_WORDS = "text_hot_words";
	public static final String TEXT_ICON = "text_icon";
	public static final String TEXT_ITEM = "text_item";
	public static final String TEXT_LANG = "text_lang";
	public static final String TEXT_LAST_REPLY = "text_last_reply";
	public static final String TEXT_LINKED = "text_linked";
	public static final String TEXT_MORE = "text_more";
	public static final String TEXT_MSG = "text_msg";
	public static final String TEXT_NAME = "text_name";
	public static final String TEXT_NAV = "text_nav";
	public static final String TEXT_NEW_PWD = "text_new_pwd";
	public static final String TEXT_NEW_PWD2 = "text_new_pwd2";
	public static final String TEXT_NOT_LINKED = "text_not_linked";
	public static final String TEXT_PAGE = "text_page";
	public static final String TEXT_PUBLISH = "text_publish";
	public static final String TEXT_PWD = "text_pwd";
	public static final String TEXT_PWD2 = "text_pwd2";
	public static final String TEXT_RANK = "text_rank";
	public static final String TEXT_RELATED = "text_related";
	public static final String TEXT_REPLY = "text_reply";
	public static final String TEXT_START = "text_start";
	public static final String TEXT_SUBMIT_MANUSCRIPT = "text_submit_manuscript";
	public static final String TEXT_SWITCH = "text_switch";
	public static final String TEXT_TAG = "text_tag";
	public static final String TEXT_TO = "text_to";
	public static final String TEXT_TODAY = "text_today";
	public static final String TEXT_TOP = "text_top";
	public static final String TEXT_TOP_OFF = "text_top_off";
	public static final String TEXT_TOPIC_RELATIONS = "text_topic_relations";
	public static final String TEXT_TYPE = "text_type";
	public static final String TEXT_USER_NAME = "text_user_name";
	public static final String TEXT_WHOLE = "text_whole";
	public static final String TITLE = "title";
	public static final String UPDATE_INDEX = "update_index";
	public static final String UPDATE_TAG = "update_tag";
	public static final String UPGRADE = "upgrade";
	public static final String USER_MANAGEMENT = "user_management";
	public static final String VIEW = "view";
	public static final String LANG = "lang";
	public static final String CONTEXT = "context";
	public static final String TRUE = "true";
	public static final String FALSE = "false";
	public static final String ENCRYPTED = "encrypted";
	public static final String MSG = "msg";
	public static final String DEFAULT_TOPIC = "default_topic";
	public static final String ACTIVATION_FIRST = "activation_first";
	public static final String ACTIVATION_LETTER_TITLE = "activation_letter_title";
	public static final String ACTIVATION_LETTER_GREETING = "activation_letter_greeting";
	public static final String ACTIVATION_LETTER_NOTE = "activation_letter_note";
	public static final String ACTIVATION__ERROR = "activation_error";
	public static final String ACTIVATION__SUCCESS = "activation_success";
	public static final String MSG_CODE_ERROR = "msg_code_error";
	static {
		messages = ConfigReader.readMessages();
		emessages = ConfigReader.readEnglishMessages();
	}

	public static Map<String, Map<String, String>> getMessages() {
		return messages;
	}

	public static Map<String, Map<String, String>> getEMessages() {
		return emessages;
	}

	public static String getELabel(String key) {
		if (emessages == null)
			emessages = ConfigReader.readEnglishMessages();
		Map<String, String> commonMap = emessages.get(MessageNamespaces.COMMON);
		if (commonMap.containsKey(key))
			return (String) commonMap.get(key);
		else {
			for (Iterator<String> iter = emessages.keySet().iterator(); iter
					.hasNext();) {
				String namespace = iter.next();

				Map<String, String> namespaceMap = emessages.get(namespace);
				if (namespaceMap.containsKey(key))
					return (String) namespaceMap.get(key);
			}
		}
		return null;
	}

	public static String getLabel(String key) {
		if (messages == null)
			messages = ConfigReader.readMessages();
		Map<String, String> commonMap = messages.get(MessageNamespaces.COMMON);
		if (commonMap.containsKey(key))
			return (String) commonMap.get(key);
		else {
			for (Iterator<String> iter = messages.keySet().iterator(); iter
					.hasNext();) {
				String namespace = iter.next();

				Map<String, String> namespaceMap = messages.get(namespace);
				if (namespaceMap.containsKey(key))
					return (String) namespaceMap.get(key);
			}
		}
		return null;
	}

	public static String getLabel(String key, String lang) {
		if (LANG_EN.equals(lang))
			return getELabel(key);
		else
			return getLabel(key);
	}

	public static void main(String args[]) {
		System.out.println(emessages.toString());
	}
}
